package river_city_ransom.tests;

import river_city_ransom.contracts.Dimensions_C;
import river_city_ransom.implementations.Dimensions_I;
import river_city_ransom.services.Dimensions;
import exceptions.ComposantError;
import junit.framework.TestCase;


public class Dimensions_T extends TestCase {
	public void test_init_ok() {
		try {
			int l = 10, h = 20, p = 5;
			Dimensions d = new Dimensions_C(new Dimensions_I(0, 0, 0));
			d.init(l, h, p);
			assertTrue(d.largeur() == l);
			assertTrue(d.hauteur() == h);
			assertTrue(d.profondeur() == p);
		}
		catch(ComposantError e) {
			System.err.println("Dimensions::test_init_ok\n\t" + e.getMessage());
			fail(e.getMessage());
		}
	}

	public void test_init_ko_1() {
		try {
			int l = -10, h = 20, p = 5;
			Dimensions d = new Dimensions_C(new Dimensions_I(0, 0, 0));
			d.init(l, h, p);
			System.err.println("Dimensions::test_init_ko_1\n\tException non levée.");
			fail("Exception non levée.");
		}
		catch(ComposantError e) {
		}
	}

	public void test_init_ko_2() {
		try {
			int l = 10, h = -20, p = 5;
			Dimensions d = new Dimensions_C(new Dimensions_I(0, 0, 0));
			d.init(l, h, p);
			System.err.println("Dimensions::test_init_ko_2\n\tException non levée.");
			fail("Exception non levée.");
		}
		catch(ComposantError e) {
		}
	}

	public void test_init_ko_3() {
		try {
			int l = 10, h = 20, p = 0;
			Dimensions d = new Dimensions_C(new Dimensions_I(0, 0, 0));
			d.init(l, h, p);
			System.err.println("Dimensions::test_init_ko_3\n\tException non levée.");
			fail("Exception non levée.");
		}
		catch(ComposantError e) {
		}
	}
}
